home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Format PITy 2009 / instaluj_pity2009.exe / {app} / Podrecznik_pity2009.chm / highlight.js < prev    next >
Text File  |  2010-02-18  |  4KB  |  119 lines

  1. // ----------------------------------------------------------------------------
  2. // Zoom Search Engine 6.0 (15/Jul/2008)
  3. // Highlight & auto-scroll script (DOM version)
  4. // jumpHL() function modified for Help & Manual Premium Pack 1.2
  5. // Script compressed with YUI compressor for Premium Pack 1.2
  6. // Original version available with Zoom Search Engine 6.0
  7. // email: zoom@wrensoft.com
  8. // www: http://www.wrensoft.com
  9. // Copyright (C) Wrensoft 2008
  10. // ----------------------------------------------------------------------------
  11. // Script options
  12. // ----------------------------------------------------------------------------
  13. // Enable or disable scroll to first match in target topic - does not work in IE6
  14. var JumpToFirstOccurance = true;
  15. // Set to false to enable search highlighting in topic headers 
  16. var SkipZoomStops = true;
  17. // ----------------------------------------------------------------------------
  18. // Main script
  19. // ----------------------------------------------------------------------------
  20. var CatchJSErrors=true;
  21. var IsZoomStop=0;
  22. function catcherror(){return true
  23. }if(CatchJSErrors){window.onerror=catcherror
  24. }function QueryString(b){var c=null;
  25. for(var a=0;
  26. a<QueryString.keys.length;
  27. a++){if(QueryString.keys[a]==b){c=QueryString.values[a];
  28. break
  29. }}return c
  30. }function QueryString_Parse(){var e=window.location.search.substring(1);
  31. var d=e.split("&");
  32. for(var b=0;
  33. b<d.length;
  34. b++){var f=d[b].indexOf("=");
  35. if(f>=0){var a=d[b].substring(0,f);
  36. var c=d[b].substring(f+1);
  37. QueryString.keys[QueryString.keys.length]=a;
  38. QueryString.values[QueryString.values.length]=c
  39. }}}QueryString.keys=new Array();
  40. QueryString.values=new Array();
  41. QueryString_Parse();
  42. function getElement(a){if(document.getElementById){return(document.getElementById(a))
  43. }else{if(document.all){return(document.all[a])
  44. }}}function findPosY(b){var a=0;
  45. if(b.offsetParent){while(b.offsetParent){a+=b.offsetTop;
  46. b=b.offsetParent
  47. }}else{if(b.y){a+=b.y
  48. }}return a
  49. }function ZRetrieveQuery(){var g=0;
  50. var a;
  51. var e;
  52. a=QueryString("zoom_highlight");
  53. if(a==""||a==null){a=QueryString("zoom_highlightsub");
  54. if(a==""||a==null){return false
  55. }else{g=1
  56. }}if((document.charset&&document.charset=="utf-8")||(document.characterSet&&document.characterSet=="UTF-8")){a=decodeURIComponent(a)
  57. }else{a=unescape(a)
  58. }a=a.toLowerCase();
  59. var d=/\"(.*?)\"|[^\\+\"]+/g;
  60. e=a.match(d);
  61. for(var c=0;
  62. c<e.length;
  63. c++){if(e[c]!=""){if(e[c].indexOf('"')!=-1){e[c]=e[c].replace(/\"/g,"");
  64. e[c]=e[c].replace(/\+/g," ")
  65. }else{e[c]=e[c].replace(/\+/g,"")
  66. }if(e[c].indexOf("*")!=-1||e[c].indexOf("?")!=-1){e[c]=e[c].replace(/\\/g," ");
  67. e[c]=e[c].replace(/\^/g," ");
  68. e[c]=e[c].replace(/\#/g," ");
  69. e[c]=e[c].replace(/\$/g," ");
  70. e[c]=e[c].replace(/\./g," ");
  71. var f=/\w/;
  72. if(f.test(e[c])){e[c]=e[c].replace(/\*/g,"[^\\s]*");
  73. e[c]=e[c].replace(/\?/g,"[^\\s]")
  74. }else{e[c]=""
  75. }}if(e[c]!=""){if(g==0){e[c]="(>[\\s]*|>[^<]+[\\b\\W])("+e[c]+")(<|[\\b\\W][^>]*<)"
  76. }else{var b="";
  77. if(e[c].substr(0,7)=="[^\\s]*"){b="\\b"
  78. }e[c]="(>|>[^<]+)"+b+"("+e[c]+")([^>]*<)"
  79. }}}}return e
  80. }function ZHighlightText(terms,text){text=text.replace(/&/ig,"&");
  81. text=text.replace(/ /ig,"");
  82. for(var i=0;
  83. i<terms.length;
  84. i++){if(terms[i]!=""){var l=0;
  85. re=new RegExp(terms[i],"gi");
  86. var count=0;
  87. text=">"+text+"<";
  88. do{l=text.length;
  89. text=text.replace(re,'$1<span class="highlight" id="highlight" name="highlight">$2</span id="highlight">$3');
  90. count++
  91. }while(l!=text.length&&count<100);
  92. text=text.substring(1,text.length-1)
  93. }}text=text.replace(eval("//g"),"");
  94. text=text.replace(eval("//g")," ");
  95. return(text)
  96. }function jumpHL(){var b=getElement("highlight");
  97. var a=$("div#idheader").height();
  98. if(b){var c=findPosY(b);
  99. if(c<a+100){$("#idcontent").scrollTo(0)
  100. }else{$("#idcontent").scrollTo(b,300,{offset:-50})
  101. }}}function ZHighlightReplace(c,a){var e=a.nodeValue;
  102. var d=ZHighlightText(c,e);
  103. if(d!=e){var b=document.createElement("span");
  104. b.innerHTML=d;
  105. a.parentNode.replaceChild(b,a)
  106. }}function ZHighlightSearch(d,a){if(!a){a=document.body.childNodes
  107. }for(var c=0,b=a.length;
  108. c<b;
  109. c++){ZHighlightSearch(d,a[c].childNodes);
  110. if(SkipZoomStops&&a[c].nodeType===8){if(a[c].nodeValue=="ZOOMSTOP"){IsZoomStop=1
  111. }else{if(a[c].nodeValue=="ZOOMRESTART"){IsZoomStop=0
  112. }}}if(IsZoomStop==0&&a[c].nodeType===3){ZHighlightReplace(d,a[c])
  113. }}}function highlight(){var a=/msie 6|MSIE 6/.test(navigator.userAgent);
  114. if(!"".match){return
  115. }if(document.body){var b=ZRetrieveQuery();
  116. if(b!=false){IsZoomStop=0;
  117. ZHighlightSearch(b);
  118. if(JumpToFirstOccurance&&!a){jumpHL()
  119. }}}};